package com.example.uiclassassignments.Activity;

import android.annotation.SuppressLint;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.ViewFlipper;

import com.example.uiclassassignments.R;

public class ViewFlipperActivity extends AppCompatActivity {
    ViewFlipper viewFlipper;

    @SuppressLint("WrongViewCast")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view_flipper);
        viewFlipper = findViewById(R.id.view_flipper);

        String[] mListValue = {"习近平在吉尔吉斯斯坦媒体发表署名文章",
                "前国家副主席王震之子王军逝世 ",
                "切尔诺贝利一日游：用旅游的方式记住灾难",
                "不忘初心,继往开来再出发",
                "油价迎今年最大降幅 有人月省千元", "杜兰特未随队回湾区"};
        for (String textTitle : mListValue) {
            TextView textView = new TextView(this);
            textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
            textView.setEllipsize(TextUtils.TruncateAt.MIDDLE);
            textView.setGravity(Gravity.CENTER);
            textView.setSingleLine(true);
            textView.setTextColor(getResources().getColor(R.color.colorPrimaryDark));
            textView.setTextSize(16);
            textView.setText(textTitle);
            viewFlipper.addView(textView);
        }
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        finish();
    }
}
